package com.zhang.controller.pay;


import com.zhang.common.util.result.R;

import com.zhang.order.service.IPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/pay")
public class PayController {
    @Autowired
    private IPayService payService;

    /**
     * 支付接口
     *
     * @param orderId
     * @return {@link R}
     */
    @RequestMapping("ali")
    public R orderPay(@RequestParam String orderId) {
        return payService.pay(orderId);
    }


    /**
     * 异步回调
     *
     * @param request
     * @return {@link String}
     */
    @PostMapping("/notify")  // 注意这里必须是POST接口
    public R payNotify(HttpServletRequest request) {
        return payService.payNotify(request);
    }

    /**
     * 查询支付结果
     *
     * @param orderId
     * @return {@link R}
     */
    @GetMapping("result")
    public R queryOrderPayResult(@RequestParam String orderId) {
        return payService.queryOrderPayResult(orderId);
    }
}
